#ifndef _UART_H_
#define _UART_H_
#include "system.h"
#include <stdarg.h>

#define Uart1_RxPin GPIO_Pin_10
#define Uart1_TxPin GPIO_Pin_9
#define Uart2_RxPin GPIO_Pin_3
#define Uart2_TxPin GPIO_Pin_2
#define Uart3_TxPin GPIO_Pin_10
#define Uart3_RxPin GPIO_Pin_11

#define MAX_DEBUG_RX_LEN 1024
#define MAX_WIFI_RX_LEN 1024
#define MAX_YUYIN_RX_LEN 512
#define DEBUG_UART USART1
#define WIFI_UART USART2
#define YUYIN_UART USART3
extern u8 u8_acDebugUartRxBuf[MAX_DEBUG_RX_LEN];
extern u16 u16_gDebugUartRxLen;

extern u8 u8_acYuyinUartRxBuf[MAX_YUYIN_RX_LEN];
extern u8 acYuyinUartRxComplete;

extern u8 u8_acWifiUartRxBuf[MAX_WIFI_RX_LEN];
extern u8 acWifiUartRxComplete;
extern u16 u16_gWifiUartRxLen ;

extern uint8_t Serial_RxFlag;
extern uint8_t Config_AT_mode;




typedef enum
{
    BaudRate2400 = 2400,
    BaudRate4800 = 4800,
    BaudRate9600 = 9600,
    BaudRate57600 = 57600
} BaudRate_t;
typedef enum
{
    STATE_IDLE,
    STATE_RECEIVING,
    STATE_COMPLETE
} RECE_STATUS_T;
typedef enum
{
    NO_REC,
    REC

} FLAG_STATUS_T;

void uart_init(void);
void vBsp_USARTDeinit(USART_TypeDef *uart);
void uart_send_byte(u8 byte, USART_TypeDef *uart);
void uart_send_string(u8 str[], USART_TypeDef *uart);
u8 uart_get_byte(u8 *val, USART_TypeDef *uart);
// u8 uart_get_byte(u8 *val);
u16 uart_get_string(u8 buf[], u16 len, USART_TypeDef *uart);
int fputc(int ch, FILE *f);
void uart_printf(char *format, ...);
// void u2_printf(char *format, ...);
void uart_SendNumber(uint32_t Number, uint8_t Length, USART_TypeDef *uart);
FLAG_STATUS_T Serial_GetRxFlag(void);
#endif
